package com.stork.cms.adapter;



import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;


import com.stork.cms.R;
import com.stork.cms.service.fees.TermFees;

public class ExpandableAdapter extends BaseExpandableListAdapter {

	private Activity activity;
	private  List<TermFees> listitem;
	private LayoutInflater inflater;

	
	
	public ExpandableAdapter(Activity activity, List<TermFees> listitem) {
		super();
		this.activity = activity;
		this.listitem = listitem;
	}

	@Override
	public Object getChild(int arg0, int arg1) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getChildId(int arg0, int arg1) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getChildView(int groupPosition, int childPosition, boolean arg2, View arg3,
			ViewGroup parent) {
		TermFees response=(TermFees) getGroup(groupPosition);
		LayoutInflater inflater = (LayoutInflater) activity
	             .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	     View rowView = inflater.inflate(R.layout.childrow, parent, false);
	    TextView treciptno,tamtperyear,tamt;
	    TextView vtreciptno,vtamtperyear,vtamt;
	    treciptno=(TextView)rowView.findViewById(R.id.treciptno);
	    tamtperyear=(TextView)rowView.findViewById(R.id.tamountperyear);
	    tamt=(TextView)rowView.findViewById(R.id.tamount);
	    vtreciptno=(TextView)rowView.findViewById(R.id.vtreciptno);
	    vtamtperyear=(TextView)rowView.findViewById(R.id.vtamountperyear);
	    vtamt=(TextView)rowView.findViewById(R.id.vtamount);
	    		vtreciptno.setText(response.getReciptno()); 
	    		vtamtperyear.setText(response.getAmountperyear());
	    		vtamt.setText(response.getTotamount());
		return rowView;
	}

	@Override
	public int getChildrenCount(int groupPosition) {
		// TODO Auto-generated method stub
		return 1;
	}

	@Override
	public Object getGroup(int groupPosition) {
		// TODO Auto-generated method stub
		return listitem.get(groupPosition);
	}

	@Override
	public int getGroupCount() {
		// TODO Auto-generated method stub
		return listitem.size();
	}

	@Override
	public long getGroupId(int groupPosition) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getGroupView(int groupPosition, boolean isExpanded,
			View convertView, ViewGroup parent) {
		TermFees response=(TermFees) getGroup(groupPosition);
		LayoutInflater inflater = (LayoutInflater) activity
	             .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	     View rowView = inflater.inflate(R.layout.grouprow, parent, false);
	    TextView groupName=(TextView)rowView.findViewById(R.id.textViewGroupName);
	    		groupName.setText(response.getPaymentname()); 
		return rowView;
	}

	@Override
	public boolean hasStableIds() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean isChildSelectable(int groupPosition, int childPosition) {
		// TODO Auto-generated method stub
		return false;
	}

}
